#include <stdio.h>
#include <algorithm>

#define MAX_N 10000
static long long selection[MAX_N];

static bool solve()
{
    int n;
    if (!(scanf("%d", &n) == 1 && n > 0))
        return false;

    for (int i = 0; i < n; i++)
    {
        /* Read the course selection of this student. */
        int id[5];
        for (int j = 0; j < 5; j++)
            scanf("%d", &id[j]);
        std::sort(id + 0, id + 5);

        /* Compute a unique key of this selection. */
        long long key = 0;
        for (int j = 0; j < 5; j++)
            key |= (long long)id[j] << (j * 9);

        selection[i] = key;
    }

    std::sort(selection + 0, selection + n);

    int count = 0;      /* number of consecutive equal items */
    int longest = 0;    /* longest number of consecutive equal items */
    int total = 0;      /* answer to the problem */
    long long last = 0; /* last key */
    for (int i = 0; i < n; i++)
    {
        if (selection[i] == last)
            ++count;
        else
            count = 1;

        if (count > longest)
        {
            longest = count;
            total = count;
        }
        else if (count == longest)
        {
            total += count;
        }
        last = selection[i];
    }

    printf("%d\n", total);
    return true;
}

int main()
{
    while (solve());
    return 0;
}
